package com.yunji.base.engine.validate;

import com.yunji.common.model.domain.SysUserDO;
import com.yunji.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author : peter-zhu
 * @date : 2025/1/8 10:30
 * @description : TODO
 **/
@Component
public class SysUserValidate {

    private static ISysUserService sysUserService;

    @Autowired
    protected void setSysUserService(ISysUserService sysUserService) {
        SysUserValidate.sysUserService = sysUserService;
    }

    public static boolean existUserName(String userName) {
        return existUserName(null, userName);
    }

    public static boolean existUserName(Long userId, String userName) {
        SysUserDO sysUserDO = new SysUserDO();
        sysUserDO.setUserId(userId);
        sysUserDO.setUserName(userName);
        return sysUserService.checkUserNameUnique(sysUserDO);
    }


}
